import axios from "src/api/common/axioswarpper.js";

let prefix = process.env.API_PREFIX;
let prefix_REAL = process.env.API_PREFIX_REAL;

export const post1 = (params, url) => axios.post(`${prefix}${url}`, params);
export const get1 = (params, url) =>
  axios.get(`${prefix}${url}`, { params: { ...params } });

// 比赛操作接口控制器    赛程  比赛

export const post_matchManager_associate = (
  params,
  url = "/matchManager/associate"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_createManageId = (
  params,
  url = "/matchManager/createManageId"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_insertS = (
  params,
  url = "/matchManager/insertS"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_insertThird = (
  params,
  url = "/matchManager/insertThird"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_merge = (
  params,
  url = "/matchManager/merge"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_modify = (
  params,
  url = "/matchManager/modify"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_queryMatch = (
  params,
  url = "football/matchManager/queryMatch"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_undoAssociate = (
  params,
  url = "/matchManager/undoAssociate"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_updateThird = (
  params,
  url = "/matchManager/updateThird"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_export = (
  params,
  url = "/matchManager/export"
) => axios.post(`${prefix}${url}`, params);
export const post_matchManager_startMatchOdds = (
  params,
  url = "/matchManager/startMatchOdds"
) => axios.post(`${prefix}${url}`, params);

// 足球球队接口控制器

export const delete_sportTeam_Byid = (params, url = "/sportTeam/") =>
  axios.delete(`${prefix}${url}${params.id}`, { params: { ...params } });
export const post_sportTeam_insert = (
  params,
  url = "/sportTeam/insert"
) => axios.post(`${prefix}${url}`, params);
export const get_sportTeam_page = (params, url = "/sportTeam/page") =>
  axios.get(`${prefix}${url}`, { params: { ...params } });
export const post_sportTeam_update = (
  params,
  url = "/sportTeam/update"
) => axios.post(`${prefix}${url}`, params);

// 足球联赛功能控制器   联赛库

export const get_tournament_Byid = (params, url = "/tournament/") =>
  axios.get(`${prefix}${url}${params.id}`, { params: { ...params } });
export const post_tournament_associate = (
  params,
  url = "/tournament/associate"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_createManageId = (
  params,
  url = "/tournament/createManageId"
) => axios.post(`${prefix}${url}`, params);

// export const post_tournament_export = (params, url="/tournament/export") => axios.post(`${prefix}${url}`, params)
// export const post_tournament_export = (params, url="/tournament/exportGet") => axios.get(`${prefix}${url}`, { params: { ...params } })

export const post_tournament_export = (
  params,
  url = "/tournament/exportGet"
) => {
  // axios.get(`${prefix}${url}`, { params: { ...params } })
  console.log( params );
  console.log(process.env);

  if (process.env.DEV) {
    prefix = process.env.API_PREFIX_REAL;
  }
  let urlp = `${prefix}${url}?`;
  let keys = Object.keys(params);
  keys.map(x => {
    console.log();
    if (params[x]) {
      urlp += `${x}=${params[x]}&`;
    }
    if(params[x]===0){
      urlp += `${x}=${params[x]}&`;
    }
  });

  console.log(keys);
  console.log(urlp);
  // return false
  window.open(urlp, "_self");
};
  // /tournament/edit
  export const post_tournament_edit = (
    params,
    url = "/tournament/edit"
  ) => axios.post(`${prefix}${url}`, params);

export const post_tournament_insertS = (
  params,
  url = "/tournament/insertS"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_insertThird = (
  params,
  url = "/tournament/insertThird"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_merge = (
  params,
  url = "/tournament/merge"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_modify = (
  params,
  url = "/tournament/modify"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_queryTour = (
  params,
  url = "/tournament/queryTour"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_undoAssociate = (
  params,
  url = "/tournament/undoAssociate"
) => axios.post(`${prefix}${url}`, params);
export const post_tournament_updateThird = (
  params,
  url = "/tournament/updateThird"
) => axios.post(`${prefix}${url}`, params);



// export const post_sportTeam_queryTeam = (
//   params,
//   url = "/sportTeam/queryTeam"
// ) => axios.post(`${prefix}${url}`, params);
